package liuliu.throughwaring.ui.activity;

import android.view.View;
import android.widget.Button;

import net.tsz.afinal.annotation.view.CodeNote;

import liuliu.custom.control.edittext.ImageEditText;
import liuliu.custom.control.toolbar.TToolbar;
import liuliu.custom.method.Utils;
import liuliu.throughwaring.R;
import liuliu.throughwaring.base.BaseActivity;
import liuliu.throughwaring.control.settting.ISettingView;
import liuliu.throughwaring.control.settting.SettingListener;

/**
 * 密码修改页面
 * Created by Administrator on 2015/11/28.
 */
public class ModifyPasswordActivity extends BaseActivity implements ISettingView {
    @CodeNote(id = R.id.modify_password_toolbar)
    TToolbar toolbar;
    @CodeNote(id = R.id.psw_old_psw)
    ImageEditText psw_old_psw;//旧密码
    @CodeNote(id = R.id.psw_new_psw)
    ImageEditText psw_new_psw;//新密码
    @CodeNote(id = R.id.sys_new_psw2)
    ImageEditText sys_new_psw2;//确认新密码
    @CodeNote(id = R.id.modify_submit)
    Button modify_submit;
    SettingListener mListener;

    @Override
    public void initViews() {
        setContentView(R.layout.activity_modify_passwrod);
        mListener = new SettingListener(this, this);
    }

    @Override
    public void initEvents() {
        toolbar.setLeftOnClick(new TToolbar.LeftOnClickListener() {
            @Override
            public void leftclick() {
                finish();
            }
        });
        modify_submit.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (checkPsw()) {
                    mListener.modifyPassword(psw_old_psw.getText().trim(), psw_new_psw.getText().trim());
                }
            }
        });
    }

    private boolean checkPsw() {
        if (!psw_new_psw.getText().trim().equals(sys_new_psw2.getText().trim())) {
            Utils.ToastShort(ModifyPasswordActivity.this, "密码输入不一致");
            return false;
        }
        return true;
    }

    @Override
    public void downLoad(boolean isTrue, String mes) {
        if (isTrue) {
            finish();
        }
        Utils.ToastShort(ModifyPasswordActivity.this, mes);
    }

    @Override
    public void DownKu(boolean isTrue) {

    }
}
